Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai

BDD/TDD assertion library for node.js and the browser. Test framework agnostic.

  • 1.10.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is chai?

Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. It provides functions to express assertions in a readable language, supporting both 'should' and 'expect' style syntaxes, as well as a traditional 'assert' style interface.

What are chai's main functionalities?

Should Style Assertions

Allows you to write assertions in a more human-readable form, which reads like English. The 'should' style extends each object with a 'should' property to start your chain.

chai.should();
var should = chai.should();
should.exist(value, 'value should not be null or undefined');

Expect Style Assertions

Provides a function called 'expect' to make assertions about values. This style is similar to 'should' but does not extend any objects, which is useful for working with libraries that don't allow object extensions.

var expect = chai.expect;
expect(value).to.exist.and.be.an('object');

Assert Style Assertions

Offers a more traditional testing interface, which is similar to Node.js' core 'assert' module but with more capabilities and better error messages.

var assert = chai.assert;
assert.typeOf(value, 'string', 'value is a string');

Chainable Language Chains

Provides chainable getters to improve the readability of your assertions, allowing you to write more expressive tests.

expect(value).to.be.an('array').that.includes(3);

Plugins

Supports plugins to extend its core functionalities, which can be used to add new assertions, matchers, or methods to the library.

var chaiHttp = require('chai-http');
chai.use(chaiHttp);

Other packages similar to chai

Keywords

FAQs

Package last updated on 10 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc